package com.rec.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.rec.service.ConsumeLogsService;

@RestController
@RequestMapping("consume")
@CrossOrigin
public class ConsumeLogsController {
		@Autowired
		private ConsumeLogsService s;
		@RequestMapping("getDo")
		public Integer GetDo(String cardno,Integer roomid) {
			return s.getDo(cardno,roomid);
		}
//		@RequestMapping("getOut")
//		public Integer GetOut(String cardno) {
//			return s.getOut(cardno);
//		}
		@RequestMapping("getAll")
		public Map<String,Object> getAll(String start,String end,String cardno,
				Integer page, Integer limit) {
			Map<String, Object> params = new HashMap<String, Object>();
			params.put("cardno", cardno);
			params.put("start", start);
			params.put("end", end);
			limit = limit == null ? 10 : limit;
			page = page == null ? 0 : page - 1;
			params.put("limit", limit);
			params.put("page", page);
			return s.all(params);
		}
}
